package org.lightrpc.format.json;

import org.lightrpc.Response;
import org.lightrpc.format.SerializationFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sdicons.json.model.JSONObject;
import com.sdicons.json.serializer.marshall.JSONMarshall;
import com.sdicons.json.serializer.marshall.Marshall;
import com.sdicons.json.serializer.marshall.MarshallException;

/**
 * This class can store the identity of the object.
 * 
 * @author miku
 * 
 */
public class JsonToolsComplexSerializer {
	private static final Logger logger = LoggerFactory
			.getLogger(JsonToolsComplexSerializer.class);

	private final Marshall marshall = new JSONMarshall();

	public Response serialize(Object object)
			throws SerializationFailedException {
		try {
			JSONObject result = marshall.marshall(object);
			return new Response(result.render(true));
		} catch (MarshallException e) {
			// TODO add more specific error message
			logger.error("", e);
			return null;
		}

	}

	public Response deserialize(Response object, Class<?> clazz) {
		// TODO Auto-generated method stub
		return null;
	}

}
